Plotting in 3D

[1]:
import numpy as np

from poliastro.examples import *
from poliastro.plotting import *
WARNING: AstropyDeprecationWarning: astropy.extern.six will be removed in 4.0, use the six module directly if it is still needed [astropy.extern.six]
[2]:
import plotly.io as pio
pio.renderers.default = "notebook_connected"
[3]:
churi.plot(interactive=True, use_3d=True)
WARNING: ErfaWarning: ERFA function "taiutc" yielded 21 of "dubious year (Note 4)" [astropy._erfa.core]
[4]:
frame = OrbitPlotter3D()

frame.plot(churi)
frame.plot(Orbit.from_body_ephem(Earth))
/home/juanlu/Development/poliastro/poliastro-library/src/poliastro/twobody/orbit.py:1163: UserWarning:

Frame <class 'astropy.coordinates.builtin_frames.icrs.ICRS'> does not support 'obstime', time values were not returned

[5]:
frame = OrbitPlotter3D()

frame.plot(molniya)
frame.plot(Orbit.from_body_ephem(Earth))
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-5-c9d0aa645ff7> in <module>
      2
      3 frame.plot(molniya)
----> 4 frame.plot(Orbit.from_body_ephem(Earth))

~/Development/poliastro/poliastro-library/src/poliastro/plotting/_base.py in plot(self, orbit, label, color)
    132             color = next(self._color_cycle)
    133
--> 134         self._set_attractor(orbit.attractor)
    135
    136         label = generate_label(orbit, label)

~/Development/poliastro/poliastro-library/src/poliastro/plotting/_base.py in _set_attractor(self, attractor)
     42         elif attractor is not self._attractor:
     43             raise NotImplementedError(
---> 44                 f"Attractor has already been set to {self._attractor.name}."
     45             )
     46

NotImplementedError: Attractor has already been set to Earth.
[6]:
frame = OrbitPlotter3D()

frame.plot(molniya)
frame.plot(iss)
[7]:
eros = Orbit.from_sbdb("eros")

frame = OrbitPlotter3D()

frame.plot(Orbit.from_body_ephem(Earth), label=Earth)
frame.plot(eros, label="eros")
/home/juanlu/Development/poliastro/poliastro-library/src/poliastro/twobody/orbit.py:1163: UserWarning:

Frame <class 'astropy.coordinates.builtin_frames.icrs.ICRS'> does not support 'obstime', time values were not returned

[8]:
from astropy.coordinates import get_body_barycentric_posvel
from poliastro.util import time_range
[9]:
date_launch = time.Time("2011-11-26 15:02", scale="utc")
date_arrival = time.Time("2012-08-06 05:17", scale="utc")

rr_earth, _ = get_body_barycentric_posvel(
    "earth", time_range(date_launch, end=date_arrival, periods=50)
)
[10]:
frame = OrbitPlotter3D()

frame.set_attractor(Sun)
frame.plot(Orbit.from_body_ephem(Earth), label=Earth)
frame.plot_trajectory(rr_earth, label=Earth)
[11]:
frame = OrbitPlotter3D()

frame.plot(eros, label="eros")
frame.plot_trajectory(rr_earth, label=Earth)